package com.kool.system.action.menu;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.kool.core.base.IBaseAction;
import com.kool.core.exception.AppException;
import com.kool.core.util.GlobalDefineUtils;
import com.kool.system.bean.vo.MenuVo;
import com.kool.system.service.MenuService;

/**
 * 
 * @DESCRIBE 查询菜单树
 * @AUTHOR LUYU
 * @DATE 2018年7月6日 下午1:57:40
 *
 */
@Controller
public class QueryMenuTreeAction implements IBaseAction {
	@Autowired
	private MenuService menuService;
	
	/**
	 * 
	 * @DESCRIBE 查询菜单树
	 * @DATE 2018年7月6日 下午1:57:17
	 *
	 * @param sInput
	 * @return
	 * @throws AppException
	 */
	@Override
	@ResponseBody
	@RequestMapping(value = "/sys/menu/queryMenuTree", method = RequestMethod.POST)
	public JSONObject doAction(@RequestBody String sInput) throws AppException {

		List<MenuVo> listMenu = menuService.queryMenuTree();
		JSONArray secOut = JSON.parseArray(JSON.toJSONString(listMenu));
		GlobalDefineUtils.addTransformation(secOut, "state", "SME_STATE");
		JSONObject pkgOut = new JSONObject();
		pkgOut.put("SYMENUTREEZ", secOut);
		return pkgOut;
	}

}
